package cn.itsource.pethome.org.service.impl;

import cn.itsource.pethome.basic.service.impl.BaseServiceImpl;
import cn.itsource.pethome.org.domain.Employee;
import cn.itsource.pethome.org.domain.Shop;
import cn.itsource.pethome.org.mapper.EmployeeMapper;
import cn.itsource.pethome.org.mapper.ShopMapper;
import cn.itsource.pethome.org.service.IEmployeeService;
import cn.itsource.pethome.org.service.IShopService;
import cn.itsource.pethome.user.domain.LoginInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ShopServiceImpl extends BaseServiceImpl<Shop> implements IShopService {

    @Autowired
    private IEmployeeService employeeService;

    @Autowired
    private ShopMapper shopMapper;
    @Override
    @Transactional
    public void settlement(Shop shop) {
        //获取店主信息
        Employee admin = shop.getAdmin();
        //保存店主信息/登录基本信息
        employeeService.save(admin);
        //保存店铺对象
        shopMapper.save(shop);
        //设置员工所属店铺
        admin.setShop(shop);
        //修改员工信息
        employeeService.update(admin);
    }
}
